<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <input type="text" id="username">
        <input type="text" id="password">
        <button id="loginBtn">登录</button>
    </div>

    <script src="./js/jquery-3.7.1.min.js"></script>
    <script>

        const username = document.getElementById('username');
        const password = document.getElementById('password');

        loginBtn.onclick = function () {

            $.ajax({
                url: 'http://nocat.life:3021/user/login',
                type: 'POST',
                data: {
                    "username": username.value,
                    "password": password.value
                },
                success(res) {
                    if(res.code == 200) {
                        alert("登录成功");
                        location.href = "./home.html";
                    }
                }
            })
        }

    </script>
</body>

</html>